{# /StudX_dir/StudX/student/templates/student/notes/student_notes.html #}

{% load i18n student_tags %}

<div class="card">
{% include 'student/notes/student_notes_filter.html' %}
   <div class="card-body">
   {% if student_notes %}
	<table class="table table-hover table-condensed table-responsive-md mx-auto mytable">
		<thead></thead>
		<tbody>
	{% for note in student_notes %}
			<tr>
				<td style="width:100%" ><div class="d-flex w-100 justify-content-between  align-middle"><h5 class="mb-1">{{note.title}}</h5> <div class="float-right"><small>{{ note.updated_at }}</small></div></div>
				{% if note.note_category %}<small>{{ note.note_category }}</small>{% endif %}
					<div id="note_content">
						{{ note.content|truncatewords_html:50 | safe }}

						<!-- Modal -->
						<div class="modal fade" id="note-{{forloop.counter}}" tabindex="-1" role="dialog" aria-labelledby="StudentNoteModalLabel" aria-hidden="true">
							<div class="modal-dialog modal-lg" role="document">
								<div class="modal-content">
									<div class="modal-header">
										<h5 class="modal-title" id="StudentNoteModalLabel">{{ note.title }}</h5>
										<button type="button" class="close" data-dismiss="modal" aria-label="Close">
											<span aria-hidden="true">&times;</span>
										</button>
									</div>
									<div class="modal-body">
										{{ note.content | safe }}
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
									</div>
								</div>
							</div>
						</div>
						<!-- Modal END -->
					</div>
					<div class="float-right"><small>{{ note.creator.get_full_name }}</small></div>
				</td>
				<td>
				{% if note.creator == request.user %}
					<div class="dropdown">
					  <a class="btn btn-sm dropdown-toggle bg-white" href="#" role="button" id="dropdownStudentNote" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></a>
					  <div class="dropdown-menu" aria-labelledby="dropdownStudentNote">
						<a class="dropdown-item text-info" href="#"  data-toggle="modal" data-target="#note-{{ forloop.counter }}"><i class="fas fa-eye mr-2"></i><span>{% trans "View" %}</span></a>
						<a class="dropdown-item text-info" href="{% url 'student:edit_student_note' student_record.uuid note.uuid %}"><i class="fas fa-pencil-alt mr-2"></i><span>{% trans "Edit" %}</span></a>
						<a class="dropdown-item text-info" href="#" data-toggle="modal" data-target="#StudentNoteDeleteModal-{{ forloop.counter }}"><i class="fas fa-trash-alt mr-2"></i><span>{% trans "Delete" %}</span></a>
					  </div>
					</div>
					<!-- Student Note Delete Modal -->
					<div class="modal" id="StudentNoteDeleteModal-{{ forloop.counter }}">
					  <div class="modal-dialog">
						<div class="modal-content">
						  <div class="modal-body">
							{% trans "Do you want to delete the note ?" %}
						  </div>
						  <div class="modal-footer">
							<form action="" method='POST'>
								{% csrf_token %}
								<button type="button" class="btn btn-danger" data-dismiss="modal">{% trans "Cancel" %}</button>
								<a class="btn btn-secondary" href="{% url 'student:delete_student_note' student_record.uuid note.uuid %}">{% trans "Confirm" %}</a>
							</form>
						  </div>
						</div>
					  </div>
					</div>
				{% endif %}
				</td>
			</tr>

				

	{% endfor %}
		</tbody>
	</table>
		{% else %}
			{% trans "Nothing found" %}
		{% endif %}
   </div>
</div>


